using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fdb;
using Fdb.Model;

namespace Model
{
    public class Test_DbContext : BaseDbContext
    {
        /// <summary>
        /// Accesslog逻辑对象
        /// </summary>
        public readonly Logic<Accesslog> Accesslog = new Logic<Accesslog>();
        /// <summary>
        /// sqlite_sequence逻辑对象
        /// </summary>
        public readonly Logic<Sqlite_sequence> Sqlite_sequence = new Logic<Sqlite_sequence>();
        /// <summary>
        /// Account逻辑对象
        /// </summary>
        public readonly Logic<Account> Account = new Logic<Account>();
        /// <summary>
        /// Affix逻辑对象
        /// </summary>
        public readonly Logic<Affix> Affix = new Logic<Affix>();
        /// <summary>
        /// Auth逻辑对象
        /// </summary>
        public readonly Logic<Auth> Auth = new Logic<Auth>();
        /// <summary>
        /// Diary逻辑对象
        /// </summary>
        public readonly Logic<Diary> Diary = new Logic<Diary>();
        /// <summary>
        /// Dic逻辑对象
        /// </summary>
        public readonly Logic<Dic> Dic = new Logic<Dic>();
        /// <summary>
        /// Dictype逻辑对象
        /// </summary>
        public readonly Logic<Dictype> Dictype = new Logic<Dictype>();
        /// <summary>
        /// Doc逻辑对象
        /// </summary>
        public readonly Logic<Doc> Doc = new Logic<Doc>();
        /// <summary>
        /// Events逻辑对象
        /// </summary>
        public readonly Logic<Events> Events = new Logic<Events>();
        /// <summary>
        /// Friend逻辑对象
        /// </summary>
        public readonly Logic<Friend> Friend = new Logic<Friend>();
        /// <summary>
        /// Message逻辑对象
        /// </summary>
        public readonly Logic<Message> Message = new Logic<Message>();
        /// <summary>
        /// Person逻辑对象
        /// </summary>
        public readonly Logic<Person> Person = new Logic<Person>();
        /// <summary>
        /// Plan逻辑对象
        /// </summary>
        public readonly Logic<Plan> Plan = new Logic<Plan>();
        /// <summary>
        /// PlanMember逻辑对象
        /// </summary>
        public readonly Logic<PlanMember> PlanMember = new Logic<PlanMember>();
        /// <summary>
        /// Suggestion逻辑对象
        /// </summary>
        public readonly Logic<Suggestion> Suggestion = new Logic<Suggestion>();
        /// <summary>
        /// Team逻辑对象
        /// </summary>
        public readonly Logic<Team> Team = new Logic<Team>();
        /// <summary>
        /// Users逻辑对象
        /// </summary>
        public readonly Logic<Users> Users = new Logic<Users>();
        /// <summary>
        /// UserToken逻辑对象
        /// </summary>
        public readonly Logic<UserToken> UserToken = new Logic<UserToken>();
        /// <summary>
        /// cust逻辑对象
        /// </summary>
        public readonly Logic<Cust> Cust = new Logic<Cust>();
        
        /// <summary>
        /// 默认构造方法
        /// </summary>
        public Test_DbContext()
        {
        
        }
        
        /// <summary>
        /// 全局数据库上下文构造方法
        /// </summary>
        /// <param name="connectionString">数据库连接字符串</param>
        public Test_DbContext(string connectionString) : base(connectionString)
        {
                this.Accesslog.ConnectionString = connectionString;
                this.Accesslog.DatabaseType = DatabaseType.SQLite;
                this.Sqlite_sequence.ConnectionString = connectionString;
                this.Sqlite_sequence.DatabaseType = DatabaseType.SQLite;
                this.Account.ConnectionString = connectionString;
                this.Account.DatabaseType = DatabaseType.SQLite;
                this.Affix.ConnectionString = connectionString;
                this.Affix.DatabaseType = DatabaseType.SQLite;
                this.Auth.ConnectionString = connectionString;
                this.Auth.DatabaseType = DatabaseType.SQLite;
                this.Diary.ConnectionString = connectionString;
                this.Diary.DatabaseType = DatabaseType.SQLite;
                this.Dic.ConnectionString = connectionString;
                this.Dic.DatabaseType = DatabaseType.SQLite;
                this.Dictype.ConnectionString = connectionString;
                this.Dictype.DatabaseType = DatabaseType.SQLite;
                this.Doc.ConnectionString = connectionString;
                this.Doc.DatabaseType = DatabaseType.SQLite;
                this.Events.ConnectionString = connectionString;
                this.Events.DatabaseType = DatabaseType.SQLite;
                this.Friend.ConnectionString = connectionString;
                this.Friend.DatabaseType = DatabaseType.SQLite;
                this.Message.ConnectionString = connectionString;
                this.Message.DatabaseType = DatabaseType.SQLite;
                this.Person.ConnectionString = connectionString;
                this.Person.DatabaseType = DatabaseType.SQLite;
                this.Plan.ConnectionString = connectionString;
                this.Plan.DatabaseType = DatabaseType.SQLite;
                this.PlanMember.ConnectionString = connectionString;
                this.PlanMember.DatabaseType = DatabaseType.SQLite;
                this.Suggestion.ConnectionString = connectionString;
                this.Suggestion.DatabaseType = DatabaseType.SQLite;
                this.Team.ConnectionString = connectionString;
                this.Team.DatabaseType = DatabaseType.SQLite;
                this.Users.ConnectionString = connectionString;
                this.Users.DatabaseType = DatabaseType.SQLite;
                this.UserToken.ConnectionString = connectionString;
                this.UserToken.DatabaseType = DatabaseType.SQLite;
                this.Cust.ConnectionString = connectionString;
                this.Cust.DatabaseType = DatabaseType.SQLite;
        }
        
        /// <summary>
        /// 创建所有系统表
        /// </summary>
        /// <returns></returns>
        public ExecuteResult CreateTable()
        {
                ExecuteResult er = new ExecuteResult();
                er = Accesslog.CreateTable();
                if (!er.Success) return er;
                er = Sqlite_sequence.CreateTable();
                if (!er.Success) return er;
                er = Account.CreateTable();
                if (!er.Success) return er;
                er = Affix.CreateTable();
                if (!er.Success) return er;
                er = Auth.CreateTable();
                if (!er.Success) return er;
                er = Diary.CreateTable();
                if (!er.Success) return er;
                er = Dic.CreateTable();
                if (!er.Success) return er;
                er = Dictype.CreateTable();
                if (!er.Success) return er;
                er = Doc.CreateTable();
                if (!er.Success) return er;
                er = Events.CreateTable();
                if (!er.Success) return er;
                er = Friend.CreateTable();
                if (!er.Success) return er;
                er = Message.CreateTable();
                if (!er.Success) return er;
                er = Person.CreateTable();
                if (!er.Success) return er;
                er = Plan.CreateTable();
                if (!er.Success) return er;
                er = PlanMember.CreateTable();
                if (!er.Success) return er;
                er = Suggestion.CreateTable();
                if (!er.Success) return er;
                er = Team.CreateTable();
                if (!er.Success) return er;
                er = Users.CreateTable();
                if (!er.Success) return er;
                er = UserToken.CreateTable();
                if (!er.Success) return er;
                er = Cust.CreateTable();
                if (!er.Success) return er;
                return er;
        }
    }
}
